package com.newjiabo.ski.service.impl;

import java.util.List;

import com.newjiabo.common.utils.DateUtils;
import com.newjiabo.common.utils.SnowFlake;
import com.newjiabo.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.newjiabo.ski.mapper.SkiOrderDetailMapper;
import com.newjiabo.ski.domain.SkiOrderDetail;
import com.newjiabo.ski.service.ISkiOrderDetailService;

/**
 * 订单详情Service业务层处理
 *
 * @author CaoMengHui
 * @date 2023-09-22
 */
@Service
public class SkiOrderDetailServiceImpl implements ISkiOrderDetailService {
    @Autowired
    private SkiOrderDetailMapper skiOrderDetailMapper;

    /**
     * 查询订单详情
     *
     * @param id 订单详情主键
     * @return 订单详情
     */
    @Override
    public SkiOrderDetail selectSkiOrderDetailById(String id) {
        return skiOrderDetailMapper.selectSkiOrderDetailById(id);
    }

    /**
     * 查询订单详情列表
     *
     * @param skiOrderDetail 订单详情
     * @return 订单详情
     */
    @Override
    public List<SkiOrderDetail> selectSkiOrderDetailList(SkiOrderDetail skiOrderDetail) {
        return skiOrderDetailMapper.selectSkiOrderDetailList(skiOrderDetail);
    }

    /**
     * 新增订单详情
     *
     * @param skiOrderDetail 订单详情
     * @return 结果
     */
    @Override
    public int insertSkiOrderDetail(SkiOrderDetail skiOrderDetail) {
        if(StringUtils.isEmpty(skiOrderDetail.getId())){
            skiOrderDetail.setId(SnowFlake.getIdStr());
        }
        skiOrderDetail.setCreateTime(DateUtils.getNowDate());
        skiOrderDetail.setDelFlag(false);
        return skiOrderDetailMapper.insertSkiOrderDetail(skiOrderDetail);
    }

    /**
     * 修改订单详情
     *
     * @param skiOrderDetail 订单详情
     * @return 结果
     */
    @Override
    public int updateSkiOrderDetail(SkiOrderDetail skiOrderDetail) {
        skiOrderDetail.setUpdateTime(DateUtils.getNowDate());
        return skiOrderDetailMapper.updateSkiOrderDetail(skiOrderDetail);
    }

    /**
     * 批量删除订单详情
     *
     * @param ids 需要删除的订单详情主键
     * @return 结果
     */
    @Override
    public int deleteSkiOrderDetailByIds(String[] ids) {
        return skiOrderDetailMapper.deleteSkiOrderDetailByIds(ids);
    }

    /**
     * 删除订单详情信息
     *
     * @param id 订单详情主键
     * @return 结果
     */
    @Override
    public int deleteSkiOrderDetailById(String id) {
        return skiOrderDetailMapper.deleteSkiOrderDetailById(id);
    }

    @Override
    public SkiOrderDetail selectSkiOrderDetailByOrderId(String orderId) {
        return skiOrderDetailMapper.selectSkiOrderDetailByOrderId(orderId);
    }
}
